package com.zhang.spark_2.com.zhang.core.transform

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @title:
 * @author: zhang
 * @date: 2022/2/14 09:50 
 */
object Spark04_mapPartitionsWithIndex {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("map")
    val sc = new SparkContext(conf)

    sc.makeRDD(List(1, 2, 3, 4, 5, 6, 7, 8),3)
      .mapPartitionsWithIndex(
        (index,list)=>{
          List((index,list.max)).iterator
        }
      )
      .collect()
      .foreach(println)

    sc.stop()

  }

}
